package com.ruoyi.common.service.business.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.pagination.PageInfo;
import com.ruoyi.common.core.pagination.Paging;
import com.ruoyi.common.domain.business.Customer;
import com.ruoyi.common.mapper.business.CustomerMapper;
import com.ruoyi.common.param.CustomerParam;
import com.ruoyi.common.service.business.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 客户Service业务层处理
 *
 * @author Song
 * @date 2024-10-29
 */
@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {

    @Autowired
    private CustomerMapper customerMapper;

    /**
     * 查询客户列表
     *
     * @param customer 客户
     * @return 客户
     */
    public Paging<Customer> pageCustomer(CustomerParam customer) {
        LambdaQueryWrapper<Customer> wrapper = new LambdaQueryWrapper<Customer>();
        Page<Customer> page = new PageInfo<>(customer);
        IPage<Customer> iPage = this.page(page, wrapper);
        // 最终返回分页对象
//        IPage<CustomerVo> resultPage = iPage.convert(item -> {
//            CustomerVo vo = new CustomerVo();
//            BeanUtil.copyProperties(item, vo);
//            return vo;
//        });
        return new Paging(iPage);
    }

}



